﻿<UserControl x:Class="Hisaab.Windows.Client.View.VehicleTransactionsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:conv="clr-namespace:Hisaab.Windows.Client.Converters" mc:Ignorable="d"
             d:DesignHeight="344" d:DesignWidth="655">
    <UserControl.Resources>
        <conv:AccountIdToNameConverter x:Key="AccountNameConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300*" />
            <ColumnDefinition Width="6" />
            <ColumnDefinition Width="300" />
        </Grid.ColumnDefinitions>
        <DataGrid Grid.Column="0" ItemsSource="{Binding Transactions}" SelectedItem="{Binding SelectedTransaction, Mode=TwoWay}"
                  AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Title}" Header="Title" Width="*" />
                <DataGridTextColumn Binding="{Binding Amount, StringFormat='{}{0:C}'}" Header="Amount" Width="Auto" />
                <DataGridTextColumn Binding="{Binding TransactionType}" Header="Type" Width="Auto" />
            </DataGrid.Columns>
        </DataGrid>
        <ListBox Grid.Column="0" ItemsSource="{Binding Transactions}" SelectedItem="{Binding SelectedTransaction, Mode=TwoWay}"
                  SelectionMode="Single" HorizontalContentAlignment="Stretch">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="25"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="100"/>
                            <ColumnDefinition Width="5"/>
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="3" Source="/Images/Small/transfer.png" />
                        <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Path=Description}" Style="{DynamicResource ListMainHeading}"/>
                        <TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding Path=Amount, StringFormat='{}{0:C}'}" Style="{DynamicResource ListSubHeading}"/>
                        <TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Path=Account, Converter={StaticResource AccountNameConverter}}" Style="{DynamicResource ListSubHeading}"/>
                        <TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding Path=Date, StringFormat=d}" Style="{DynamicResource ListSubHeading}"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <GridSplitter VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Column="1"/>
        <ContentControl Grid.Column="2" Content="{Binding SelectedVehicleTransactionViewModel}" ContentTemplateSelector="{StaticResource hisaabDataTemplateSelector}"/>
    </Grid>
</UserControl>